﻿Imports System.Data
Imports VSModel
Imports Cls_Common

Partial Class Control_Scholarship_Detail
    Inherits System.Web.UI.UserControl
#Region "Sub and Function "
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Not Request.QueryString("Id").ToString.Equals("0") Then
                hidID.Value = Request.QueryString("Id")
                ShowData()
            End If
        End If
    End Sub
    Protected Sub ShowData()
        Using data As New VSEntities
            Dim p = (From q In data.Feedbacks, a In data.Status Where q.ID = hidID.Value And a.StatusId = q.StatusId
                     Select New With {q.ID, q.FullName, q.Email, q.Phone, q.Title, q.Content, q.Created, q.Creator, _
                                      q.Modifier, q.Modified, q.PublishedDate, _
                                     .StatusName = a.Title, q.Address, q.bEffectiveDate, q.eEffectiveDate}).ToList
            If Not p Is Nothing Then
                Dim _id As Integer = p(0).ID
                lblFullName.Text = p(0).FullName
                lblEmail.Text = p(0).Email
                lblPhone.Text = p(0).Phone
                lblAddress.Text = p(0).Address
                lblTitle.Text = p(0).Title
                txtDetail.Text = p(0).Content
                lblStatus.Text = p(0).StatusName
                lblCreated.Text = IIf(IsNothing(p(0).Created) = True, "", Convert.ToDateTime(p(0).Created).ToString("dd/MM/yyyy"))
                lblCreator.Text = IIf(IsNothing(p(0).Creator) = True, "", p(0).Creator)
                lblModified.Text = IIf(IsNothing(p(0).Modified), "", Convert.ToDateTime(p(0).Modified).ToString("dd/MM/yyyy"))
                lblModifier.Text = IIf(IsNothing(p(0).Modifier) = True, "", p(0).Modifier)
                lblPublisheddate.Text = IIf(IsNothing(p(0).PublishedDate), "", Convert.ToDateTime(p(0).PublishedDate).ToString("dd/MM/yyyy"))
                lblBeffectivedate.Text = IIf(IsNothing(p(0).bEffectiveDate), "", Convert.ToDateTime(p(0).bEffectiveDate).ToString("dd/MM/yyyy"))
                lblEeffectivedate.Text = IIf(IsNothing(p(0).eEffectiveDate), "", Convert.ToDateTime(p(0).eEffectiveDate).ToString("dd/MM/yyyy"))

            End If
        End Using
    End Sub
     
#End Region
#Region "Event for control"
    Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnBack.Click
        Response.Redirect("List.aspx")
    End Sub
#End Region
End Class
